package DAO;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;

import Beans.CartaBean;
import Beans.ComandaBean;
import Beans.ProductoBean;
import Beans.RecetaBean;
import Beans.SalonBean;
import HibernateUtils.HibernateUtil;
import Model.Receta;

public class HibernateRecetaDAO {
	private static HibernateRecetaDAO instancia = null;
	private static SessionFactory sf = null;

	public static HibernateRecetaDAO getInstancia(){
		if(instancia == null){
			sf = HibernateUtil.getSessionFactory();
			instancia = new HibernateRecetaDAO();
		} 
		return instancia;
	}
	
	public void grabarReceta(RecetaBean receta){
		Session sesion= sf.openSession();
		sesion.beginTransaction();
		sesion.persist(receta);
		sesion.flush();
		sesion.getTransaction().commit();
		sesion.close();
	}

	public RecetaBean buscarReceta(RecetaBean recetab) {
		Session session=sf.openSession();
		RecetaBean receta=(RecetaBean) session.get(RecetaBean.class, recetab.getId());
		session.close();
		return receta;
	}

	
	

	

	
}
